import requests
import json

def send_dingtalk_message(token, message):
    # headers = {
    #     'Content-Type': 'application/json'
    # }
    data = {
        "msgtype": "text",
        "text": {
            "content": message
        }
    }
    webhook_url = "https://oapi.dingtalk.com/robot/send?access_token="+token
    response = requests.post(webhook_url, json=data)
    print(response.text)
    return response.status_code

def main():
    # 替换为您的钉钉机器人Webhook地址
    #webhook_url = "https://oapi.dingtalk.com/robot/send?access_token=your_access_token"
    # 邮件提醒消息内容
    message = "您有一封新邮件，请及时查收！"
    # 发送钉钉消息
    status_code = send_dingtalk_message('token', message)
    if status_code == 200:
        print("邮件提醒发送成功！")
    else:
        print(f"邮件提醒发送失败，状态码：{status_code}")

if __name__ == "__main__":
    main()